<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_SessionformationHasParticipant extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(50)
     *
     * @var int
     */
    protected $_SessionformationIdSess;

    /**
     * Database var type varchar(8)
     *
     * @var string
     */
    protected $_ParticipantCin;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_Datevalidation;


    /**
     * Parent relation fk_sessionformation_has_participant_participant1
     *
     * @var Application_Model_Participant
     */
    protected $_Participant;

    /**
     * Parent relation fk_sessionformation_has_participant_sessionformation1
     *
     * @var Application_Model_Sessionformation
     */
    protected $_Sessionformation;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'sessionformation_id_sess'=>'SessionformationIdSess',
            'participant_cin'=>'ParticipantCin',
            'datevalidation'=>'Datevalidation',
        ));

        $this->setParentList(array(
            'FkSessionformationHasParticipantParticipant1'=> array(
                    'property' => 'Participant',
                    'table_name' => 'Participant',
                ),
            'FkSessionformationHasParticipantSessionformation1'=> array(
                    'property' => 'Sessionformation',
                    'table_name' => 'Sessionformation',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column sessionformation_id_sess
     *
     * @param int $data
     * @return Application_Model_SessionformationHasParticipant
     */
    public function setSessionformationIdSess($data)
    {
        $this->_SessionformationIdSess = $data;
        return $this;
    }

    /**
     * Gets column sessionformation_id_sess
     *
     * @return int
     */
    public function getSessionformationIdSess()
    {
        return $this->_SessionformationIdSess;
    }

    /**
     * Sets column participant_cin
     *
     * @param string $data
     * @return Application_Model_SessionformationHasParticipant
     */
    public function setParticipantCin($data)
    {
        $this->_ParticipantCin = $data;
        return $this;
    }

    /**
     * Gets column participant_cin
     *
     * @return string
     */
    public function getParticipantCin()
    {
        return $this->_ParticipantCin;
    }

    /**
     * Sets column datevalidation
     *
     * @param date $data
     * @return Application_Model_SessionformationHasParticipant
     */
    public function setDatevalidation($data)
    {
        $this->_Datevalidation = $data;
        return $this;
    }

    /**
     * Gets column datevalidation
     *
     * @return date
     */
    public function getDatevalidation()
    {
        return $this->_Datevalidation;
    }

    /**
     * Sets parent relation ParticipantCin
     *
     * @param Application_Model_Participant $data
     * @return Application_Model_SessionformationHasParticipant
     */
    public function setParticipant(Application_Model_Participant $data)
    {
        $this->_Participant = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['cin'];
        }

        $this->setParticipantCin($primary_key);

        return $this;
    }

    /**
     * Gets parent ParticipantCin
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Participant
     */
    public function getParticipant($load = true)
    {
        if ($this->_Participant === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationHasParticipantParticipant1', $this);
        }

        return $this->_Participant;
    }

    /**
     * Sets parent relation SessionformationIdSess
     *
     * @param Application_Model_Sessionformation $data
     * @return Application_Model_SessionformationHasParticipant
     */
    public function setSessionformation(Application_Model_Sessionformation $data)
    {
        $this->_Sessionformation = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_sess'];
        }

        $this->setSessionformationIdSess($primary_key);

        return $this;
    }

    /**
     * Gets parent SessionformationIdSess
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sessionformation
     */
    public function getSessionformation($load = true)
    {
        if ($this->_Sessionformation === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationHasParticipantSessionformation1', $this);
        }

        return $this->_Sessionformation;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_SessionformationHasParticipant
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_SessionformationHasParticipant());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_SessionformationHasParticipant::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        $primary_key = array();
        if (! $this->getSessionformationIdSess()) {
            throw new Exception('Primary Key SessionformationIdSess does not contain a value');
        } else {
            $primary_key['sessionformation_id_sess'] = $this->getSessionformationIdSess();
        }

        if (! $this->getParticipantCin()) {
            throw new Exception('Primary Key ParticipantCin does not contain a value');
        } else {
            $primary_key['participant_cin'] = $this->getParticipantCin();
        }

        return $this->getMapper()->getDbTable()->delete('sessionformation_id_sess = '
                    . $this->getMapper()->getDbTable()->getAdapter()->quote($primary_key['sessionformation_id_sess'])
                    . ' AND participant_cin = '
                    . $this->getMapper()->getDbTable()->getAdapter()->quote($primary_key['participant_cin']));
    }
}
